package com.seventh.parkingrent.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.seventh.parkingrent.controller.form.RentMessageForm;
import com.seventh.parkingrent.domain.RentMessage;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.seventh.parkingrent.domain.Vo.UpdateStatusByidVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 订单详情记录表 Mapper 接口
 * </p>
 *
 * @author Lucas
 * @since 2021-08-24
 */
public interface RentMessageMapper extends BaseMapper<RentMessage> {

    @Update("UPDATE pr_rent_message SET status=1,tenantry_id=#{tenantryId} WHERE rent_message_id=#{rentMessageId}")
    int updateStatusByid (UpdateStatusByidVo vo);



    @Select("SELECT rent_message_id,rentype,rent_start_time,rent_end_time,p1.parking_space_addr,p2.property_name,status,cost,r.row_add_time FROM pr_rent_message r JOIN pr_parking_space p1 ON r.property_manager_id = p1.property_manager_id  JOIN pr_property_manager p2 ON p1.property_manager_id = p2.property_manager_id WHERE r.lessor_id = #{lessorId}")
    public IPage<RentMessageForm> findRent(IPage<RentMessageForm> page, @Param("lessorId") int lessorId);


    @Select("SELECT rent_message_id,rentype,rent_start_time,rent_end_time,p1.parking_space_addr,p2.property_name,status,cost,r.row_add_time FROM pr_rent_message r JOIN pr_parking_space p1 ON r.property_manager_id = p1.property_manager_id  JOIN pr_property_manager p2 ON p1.property_manager_id = p2.property_manager_id WHERE r.rent_message_id = #{rentMessageId}")
    public List<RentMessageForm> findById(int rentMessageId );


    @Select("select * from  pr_rent_message where spacing_space_id=#{spacingSpaceId}")
    List<RentMessage> findOrderTime(int spacingSpaceId);
}
